package com.hx.er.action.base;

import com.hx.er.common.exception.ErRuntimeException;
import com.hx.er.common.system.ErRestraurant;
import com.hx.er.common.util.StringUtil;

public class ErCustomerAction extends ErBaseAction {

	private static final long serialVersionUID = 8566755185185690043L;
	
	protected long restId;

	public ErCustomerAction() {
		// 父类构造方法
		super();

		// 取出域名、餐馆ID
		String currentServerName = this.request.getServerName();
		if (!StringUtil.isEqual(this.serverName, currentServerName)) {
			this.serverName = currentServerName;

			// 如果用IP直接访问，则抛出异常
			if (ErRestraurant.getRestByServerName(this.serverName) == null) {
				throw new ErRuntimeException("PLEASE USE SERVER NAME!");
			} else {
				this.restId = ErRestraurant.getRestByServerName(this.serverName).getRestId();
			}
		}
	}

	public long getServerRestId() {
		return restId;
	}
}
